<?php

/**
* @desc Просмотр результатов теста.
* 
*/
class Results_Backend_Statistic_Details extends Tests_Frontend_End_Results 
{
    
    /**
    * @param integer
    * 
    */
    protected $_user_id;
    
    /**
     * Реализация обработки пользовательского запроса.
     *
     */
    protected function _process() 
    {
        Application::getResponse()->setTitle(__('RESULTS'));
        
        $this->_user_id = (int)Application::getRequest()->get('id');
        if (!count($results = $this->_getResults($this->_user_id))) return;
        
        $entries = Tests_Utils::explode($results, 'answers', 'right');
        Application::getResponse()->assign(array(
            'entries' => $entries, 
            'rate' => $this->_getRating($entries, $this->_getTestId()), 
            ));
    }
    
    private function _getTestId() 
    {
        $query = '
            SELECT 
                   `tests_group` 
              FROM 
                   `user_answers` 
             WHERE 
                   `user_id` = ' . $this->_user_id . '
             LIMIT 1
             ';
        return database::fetchOne($query);
    }
    
}